<template>
    <el-container class="sys_parameter">
        <el-main>
            <el-card class="box-card">
                <div class="buttons">
                    <el-row :gutter="15">
                        <el-col :span="16">
                            <el-button icon="el-icon-refresh-right" @click="getList"/>
                        </el-col>
                        <el-col :span="8">
                            <el-button icon="el-icon-search" @click="getList"/>
                        </el-col>
                    </el-row>
                </div>
                <vxeTableTemplate :data="dataList" :options.sync="tableOptions" @handleSelectionChange="handleSelectionChange"
                                  @handleChangePage="handleChangePage"/>
            </el-card>

        </el-main>
    </el-container>
</template>

<script>
    import sysPerformanceApi from "@common/api/system/sysPerformanceApi";

    export default {
        name: "SysPerformance",
        data () {
            let $this = this;
            return {
                dataList: [],
                tableOptions: {
                    ref: 'ParameterTable',
                    container: '#parameter_container',
                    multiSelect: true,
                    columns: [{
                        label: '方法名',
                        prop: 'class_method',
                        align: 'left',
                    }, {
                        label: '调用次数',
                        prop: 'count',
                        align: 'right',
                        width:80,
                    }, {
                        label: '平均时长（毫秒）',
                        prop: 'avg',
                        align: 'right',
                        width:120,
                    }, {
                        label: '最大时长',
                        prop: 'max',
                        align: 'right',
                        width:80,
                    }, {
                        label: '最小时长',
                        prop: 'min',
                        align: 'right',
                        width:80,
                    }],
                },
            }
        },
        mounted () {
            this.getList();
        },
        methods: {
            getList () {
                let $this = this;
                let queryData = {}
                $this.dataList = [];
                queryData = $this.getQueryParams($this.tableOptions, queryData);
                sysPerformanceApi.getControllerMethodDurations(queryData, result => {
                    $this.dataList = result.data || [];
                    $this.tableOptions = $this.setTableTotal($this.tableOptions, result);
                })
            },
        },
    }
</script>

<style lang="less" rel="stylesheet/less" scoped>
    .sys_parameter {
        height: 100%;

        .buttons {
            margin: 0 0 10px 0;
        }
    }
</style>
